<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <div th:replace="authority/common/currency/head"></div>
    <link rel="stylesheet" th:href="@{/authority/css/form-auto.css}">
</head>
<body class="childrenBody" padding10>
<div style="padding-top: 20px">
    <!--/*@thymesVar id="user" type="com.zengdada.authority.model.AppUser"*/-->
    <form class="layui-form layui-form-pane zsa-form" th:action="@{/authority/user/save.do}" method="post"
          lay-filter="form" onsubmit="return false">
        <input type="hidden" name="id" th:value="${user!=null?user['id']:''}">
        <div class="layui-row layui-col-space15 layui-form-item">
            <div class="layui-col-md6">
                <label for="B_account" class="layui-form-label"><span class="x-red">*</span>账号</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="B_account" name="account" lay-verify="required"
                           placeholder="账号" autocomplete="off" th:value="${user!=null?user['account']:''}">
                </div>
                <div class="layui-form-mid layui-word-aux zsa-word-aux">登录时使用</div>
            </div>
            <div class="layui-col-md6">
                <label for="B_password" class="layui-form-label"><span class="x-red">*</span>密码</label>
                <div class="layui-input-block">
                    <input type="password" class="layui-input" id="B_password" name="password" lay-verify="required"
                           placeholder="密码" autocomplete="off" th:value="${user!=null?user['password']:''}">
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space15 layui-form-item">
            <div class="layui-col-md6">
                <label for="B_name" class="layui-form-label"><span class="x-red">*</span>姓名</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="B_name" name="name" lay-verify="required"
                           th:value="${user!=null?user['name']:''}"
                           placeholder="真实姓名" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-md6">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block" pane>
                    <input type="radio" name="sex" value="1" title="男" th:checked="${user!=null?user['sex']==1:false}">
                    <input type="radio" name="sex" value="0" title="女" th:checked="${user!=null?user['sex']==0:false}">
                </div>
            </div>
        </div>
        <div class="layui-row layui-col-space15 layui-form-item">
            <div class="layui-col-md6">
                <label for="B_phone" class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="B_phone" name="phone"
                           th:value="${user!=null?user['phone']:''}"
                           placeholder="手机号码" autocomplete="off">
                </div>
            </div>
            <div class="layui-col-md6">
                <label for="B_idCard" class="layui-form-label">身份证</label>
                <div class="layui-input-block">
                    <input type="text" class="layui-input" id="B_idCard" name="idCard"
                           th:value="${user!=null?user['idCard']:''}"
                           placeholder="身份证号码" autocomplete="off">
                </div>
            </div>
        </div>

        <div class="layui-form-item" pane>
            <label class="layui-form-label"><span class="x-red">*</span>状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="state" lay-skin="switch" lay-text="正常|无效"
                       th:checked="${user!=null?user['sex']==1:true}">
            </div>
        </div>

        <div class="layui-form-item">
            <button class="layui-btn" id="my-submit" lay-filter="submit" lay-submit> 提 交</button>
        </div>
    </form>
</div>
<div th:replace="authority/common/currency/footer"></div>
<script>
    layui.use(['form', 'lutil'], function () {
        var form = layui.form,
            lutil = layui.lutil,
            layer = layui.layer;

        form.on('submit(submit)', function (formData) {
            var loding = layer.load(2, {shade: [0.3, '#eee']});
            formData.field['state'] = (formData.field['state'] == 'on' ? 1 : 0);
            ajaxRequestByCsrf($(formData.form).attr('action'), formData.field
                , function (res) {
                    lutil.success_msg(res.message);
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index);
                }, null, function (res) {
                    layer.close(loding);
                })
        })
    })

</script>
</body>
</html>